package e3;

import java.util.Scanner; 

public class Main {

	public static void main(String[] args) {
		
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		Person[] person=new Person[n];
		for(int i=0;i<=n-1;i++)
		{
			String name=s.next();
			int age=s.nextInt();
			boolean gender=s.nextBoolean();
			person[i]=new Person(name,gender,age);
		}
		for(int i=n-1;i>=0;i--)
     {System.out.println(person[i]);}
     System.out.println(new Person());
     
		}

}